<!DOCTYPE html>
<html>
<head>
<title>房屋管理系统</title>

<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">

<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
<link rel="stylesheet" type="text/css" href="css/mainStyle.css">
<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript" src="js/jquery-1.11.1.js"></script>
<script type="text/javascript" src="js/cookie_util.js"></script>
<script type="text/javascript">
	window.onload = function() {changeDiv();};
	$(function(){
        $(function(){
            //登录
            $("#clickLogin").click(function(){
                var userName = $("#usernameLogIn").val();
                var password = $("#psdLogIn").val();
                $.ajax({
                    url:"/HouseRent/login/login.do",
                    type:"post",
                    data:{"userName":userName,"password":password},
                    dataType:"json",
                    success:function(result){
                        if("0000"==result.status){
                            var user = result.data;
                            addCookie("userId",user.user_id,2);
                            addCookie("userName",user.real_name,2);
                            addCookie("isFull",user.is_full,2);
                            addCookie("userType",user.user_type,2);
                            if("01"==user.user_type){//住户
                                window.location.href="personPage.html";
                            }else{
                                window.location.href="homePage.html";
                            }
                        }else{
                            alert(result.detail);
                        }
                    },
                    error:function(){
                        alert("系统异常,请稍后重试");
                    }
                });
            });
            
            //注册
            $("#register").click(function(){
                var userName = $("#username").val();
                var password = $("#psd").val();
                var realPassword = $("#psd1").val();
                var telPhone = $("#telPhone").val();
                if(""==password || password!=realPassword){
                    alert("密码为空或两次输入的密码不一致!");
                    return;
                }
                $.ajax({
                    url:"/HouseRent/login/register.do",
                    type:"post",
                    data:{"userName":userName,"password":password,"telPhone":telPhone,"userType":"00"},
                    dataType:"json",
                    success:function(result){
                        alert(result.detail);
                        if("0000"==result.status){
                            $("#username").val("");
                            $("#psd").val("");
                            $("#psd1").val("");
                            $("#telPhone").val("");
                            log_method();
                        }
                    },
                    error:function(){
                        alert("系统异常,请稍后重试");
                    }
                });
            });
        });
	});
</script>

</head>

<body>
	<div class="sign">
		<div class="log">
			<!-- 登陆 -->
			<div class="login-func">
				<h2>
					<a class="active cursor-pointer" href="javascript:void(0);" onclick="log_method()" id="logbut1">登录</a><span id="shuxian">|</span><a
						class="cursor-pointer"  href="javascript:void(0);" onclick="res_method()" id="resbut1">注册</a>
				</h2>
				<div class="form-container">
					<div id="login">
						<input id="usernameLogIn" class="xsd-input" type="text" name="username"
							placeholder="请输入帐号" autocomplete="off" title="您的帐号"
							validate="required"><br /> <input id="psdLogIn"
							placeholder="请输入密码" title="您的密码" autocomplete="off"
							name="password" type="password"
							class="xsd-input ember-view ember-text-field">
					</div>
				</div>
				<div class="input-group">
					<a href="javaScript:void(0)" class="btn-primary" id="clickLogin">立即登录</a>
				</div>
				<!-- <div class="forget-link">
					<a class="forgetpsd" target="forgetPsd" href="">忘记密码?</a>
				</div> -->
			</div>

			<!-- 注册 -->
			<div class="resin-func">
				<h2>
					<a class="active cursor-pointer" href="javascript:void(0);" onclick="log_method()" id="logbut2">登录</a><span id="shuxian">|</span><a
						class="cursor-pointer"  href="javascript:void(0);" onclick="res_method()" id="resbut2">注册</a>
				</h2>
				<div class="form-container">
					<div id="login">
						<input id="username" class="xsd-input" type="text" name="username"
							placeholder="请输入帐号/邮箱" autocomplete="off" title="您的帐号"
							validate="required"><br/> 
						<input id="psd" placeholder="请输入密码" title="您的密码" autocomplete="off"
							name="password" type="password"
							class="xsd-input ember-view ember-text-field"><br/> 
						<input id="psd1"
							placeholder="请确认密码" title="您的密码" autocomplete="off"
							name="password" type="password"
							class="xsd-input ember-view ember-text-field"><br/> 
						<input id="telPhone" type="text" class="xsd-input" autocomplete="off" title="手机号" placeholder="请输入有效联系方式"/>
					</div>
				</div>
				<div class="input-group">
					<a href="javaScript:void(0)" class="btn-primary" id="register">立即注册</a>
				</div>
				<!-- <div class="forget-link">
					<a class="forgetpsd" target="forgetPsd" href="javaScript:void(0)">忘记密码?</a>
				</div> -->
			</div>
		</div>
	</div>
</body>
</html>
